<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */

namespace App\Utils;

use Hyperf\Context\ApplicationContext;
use Hyperf\Logger\LoggerFactory;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;

class Log
{
    public static function __callStatic($name, $arguments)
    {
        self::getInstance()->{$name}(...$arguments);
    }

    public static function getInstance(string $name = 'app')
    {
        try {
            return ApplicationContext::getContainer()->get(LoggerFactory::class)->get($name);
        } catch (NotFoundExceptionInterface|ContainerExceptionInterface $e) {
        }
    }
}
